package View;

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.StageStyle;

import java.io.IOException;

public class SelectHeadWindow extends window{
        public SelectHeadWindow () throws IOException {
            root = FXMLLoader.load(getClass().getResource("/Fxml/selectHead.fxml"));
            Scene scene = new Scene(root, 600, 400);
            scene.setFill(Color.TRANSPARENT);
            setScene(scene);
            initStyle(StageStyle.TRANSPARENT);
            setResizable(false);
            setTitle("We Chat");
            Image image=new Image("/Picture/sourceMaterial/选择个人头像背景图.jpg",612,400,false,false);
            ((ImageView)$("backgroundImage")).setImage(image);
            move();
            quit();
            setIcon();
            minimiser();
        }


        //退出
        @Override
        public void quit() {
            ((Button) $("exitButton")).setTooltip(new Tooltip("退出"));
            ((Button) $("exitButton")).setOnAction(event -> {
                close();
            });

        }
        //最小化
        @Override
        public void minimiser() {
            ((Button) $("ministerButton")).setTooltip(new Tooltip("最小化"));
            ((Button) $("ministerButton")).setOnAction(event -> {
                setIconified(true);
            });
        }
        public void InitHead(){
            ((ImageView)$("happyImage")).setImage(new Image("/Picture/headPortrait/喜羊羊.jpeg", 80, 80, false, false));
            ((ImageView)$("happyImage")).setClip(getCircle());
            ((ImageView)$("beautifulImage")).setImage(new Image("/Picture/headPortrait/美羊羊.jpg", 80, 80, false, false));
            ((ImageView)$("beautifulImage")).setClip(getCircle());
            ((ImageView)$("excitedImage")).setImage(new Image("/Picture/headPortrait/沸羊羊.jpg", 80, 80, false, false));
            ((ImageView)$("excitedImage")).setClip(getCircle());
            ((ImageView)$("lazyImage")).setImage(new Image("/Picture/headPortrait/懒羊羊.jpg", 80, 80, false, false));
            ((ImageView)$("lazyImage")).setClip(getCircle());
            ((ImageView)$("warmImage")).setImage(new Image("/Picture/headPortrait/暖羊羊.jpg", 80, 80, false, false));
            ((ImageView)$("warmImage")).setClip(getCircle());
            ((ImageView)$("villageImage")).setImage(new Image("/Picture/headPortrait/村长.jpg", 80, 80, false, false));
            ((ImageView)$("villageImage")).setClip(getCircle());
            ((ImageView)$("grayImage")).setImage(new Image("/Picture/headPortrait/灰太狼.jpeg", 80, 80, false, false));
            ((ImageView)$("grayImage")).setClip(getCircle());
            ((ImageView)$("redImage")).setImage(new Image("/Picture/headPortrait/红太狼.jpg", 80, 80, false, false));
            ((ImageView)$("redImage")).setClip(getCircle());
            ((ImageView)$("bananaImage")).setImage(new Image("/Picture/headPortrait/蕉太狼.jpeg", 80, 80, false, false));
            ((ImageView)$("bananaImage")).setClip(getCircle());
            ((ImageView)$("smallImage")).setImage(new Image("/Picture/headPortrait/小灰灰.jpg", 80, 80, false, false));
            ((ImageView)$("smallImage")).setClip(getCircle());
        }
        public Circle getCircle(){
            Circle circle = new Circle();
            circle.setRadius(40);
            circle.setCenterX(40);
            circle.setCenterY(40);
            return circle;
        }
}
